package com.acp.controller;

import com.acp.param.DcsCollectCodeParam;
import com.acp.result.PageResult;
import com.acp.result.ResultInfo;
import com.acp.service.DcscollectCodeService;
import com.acp.util.BeanValidator;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * All rights Reserved, Designed By 姑苏区政府大数据中心
 *
 * @version V1.0
 * @Title: null.java
 * @Package com.dci.controller.construction
 * @Description: 采集编号管理
 * @author: 张星亮
 * @date: 2019/4/5
 * @Copyright: 2019 姑苏区政府大数据中心. All rights reserved.
 * 注意：本内容仅限于姑苏区政府大数据中心内部传阅，禁止外泄以及用于其他的商业目
 */

@Controller
@RequestMapping("/collect")
public class DcsCollectCodeController {
    @Resource
    private DcscollectCodeService dcscollectCodeService;

    /**
     * 新增
     *
     * @param dcsCollectCodeParam
     * @return ResultInfo 封装的返回参数  保存成功msg:906 保存失败msg:911
     * @throws Exception
     */
    @PostMapping("/addCode")
    @ResponseBody
    @ApiOperation(value = "新增", notes = "新增")
    @ApiImplicitParam(paramType = "body", name = "dcsCollectCodeParam", value = "编码", required = true, dataType = "DcsCollectCodeParam")
    public ResultInfo addGisElement(@RequestBody DcsCollectCodeParam dcsCollectCodeParam) throws Exception {
        BeanValidator.check(dcsCollectCodeParam);
        return dcscollectCodeService.addDcsTask(dcsCollectCodeParam);
    }

    /**
     * 根据主键删除
     *
     * @param list
     * @return ResultInfo 封装的返回参数  保存成功msg:906 保存失败msg:911
     */
    @PostMapping("/deleteCode")
    @ResponseBody
    @ApiOperation(value = "删除", notes = "删除")
    @ApiImplicitParam(paramType = "body", name = "list", value = "编码", required = true, dataType = "List<DcsCollectCodeParam>")
    public ResultInfo deleteGisElementById(@RequestBody List<DcsCollectCodeParam> list) {
        ResultInfo resultInfo = dcscollectCodeService.deleteDcsTaskById(list);
        return resultInfo;
    }

    /**
     * 编辑
     *
     * @param dcsCollectCodeParam
     * @return ResultInfo 封装的返回参数  保存成功msg:906 保存失败msg:911
     * @throws Exception
     */
    @PostMapping("/editCode")
    @ResponseBody
    @ApiOperation(value = "编辑", notes = "编辑")
    @ApiImplicitParam(paramType = "body", name = "dcsCollectCodeParam", value = "编码", required = true, dataType = "DcsCollectCodeParam")
    public ResultInfo editGisElement(@RequestBody DcsCollectCodeParam dcsCollectCodeParam) throws Exception {
        BeanValidator.check(dcsCollectCodeParam);
        return dcscollectCodeService.editDcsTask(dcsCollectCodeParam);
    }

    /**
     * 查询所有信息
     *
     * @return PageResult 封装的返回参数  保存成功msg:906 保存失败msg:911
     */
    @PostMapping("/queryCodeAll")
    @ResponseBody
    public PageResult queryGisElementList() {
        PageResult pageResult = dcscollectCodeService.queryCodeAll();
        return pageResult;
    }
}
